<div class="review-nav">
    <ul class="clearfix">
        <li data-type="0" data-category="0" class="on"><span class="divide"></span><a
                href="javascript:void(0);"><span>全部</span></a></li>
        <li data-type="0" data-category="2" class="">
            <span class="divide"></span>
            <a href="javascript:void(0);"><span>有图</span><span class="num"> (1356条)</span></a>
        </li>
        <li data-type="1" data-category="13" class="">
            <span class="divide"></span>
            <a href="javascript:void(0);">
                <span>好评</span>
                <span class="num">（4749条）</span>
            </a>
        </li>
        <li data-type="1" data-category="12" class="">
            <span class="divide"></span>
            <a href="javascript:void(0);">
                <span>中评</span>
                <span class="num">（750条）</span>
            </a>
        </li>
        <li data-type="1" data-category="11" class="">
            <span class="divide"></span>
            <a href="javascript:void(0);">
                <span>差评</span>
                <span class="num">（93条）</span>
            </a>
        </li>
        <li data-type="2" data-category="178487584" class="">
            <span class="filter-word divide"></span>
            <a href="javascript:void(0);">标志性建筑<span class="num">（535人提及）</span></a>
        </li>
    </ul>
</div>

<div class="loading-img" style="display: none;"><img
        src="http://images.mafengwo.net/images/weng/loading3.gif"> Loading...
</div>

<#if page.content??>
    <div class="_j_commentlist">
        <div class="rev-list">
            <ul id="commentList">
            <#list page.content as c>
                <li class="rev-item comment-item clearfix">
                    <div class="user"><a class="avatar" href="#" target="_blank"><img
                            src="${c.headUrl}"
                            width="48" height="48"></a><span class="level">LV.${c.level}</span></div>
                    <a class="useful" data-id="191407415" title="点赞">
                        <i></i><span class="useful-num">0</span>
                    </a>
                    <a class="name" href="#" target="_blank">${c.username}</a>
                    <span class="s-star s-star${c.rank}"></span>
                    <p class="rev-txt">
                        ${c.content}
                    </p>

                    <div class="info clearfix">
                        <a class="btn-comment _j_comment" id="${c._id}" title="添加评论">评论</a>
                        <span class="time">${c.createTime?string('yyyy-MM-dd HH:mm:ss')}</span>
                    </div>

                    <#--<#if c.refScenicComments?size == 0>
                    <div class=" add-reply ">
                        <ul class="more_reply_box comment_list" id="ul${c._id}">
                        </ul>
                    </div>
                    <#else>-->
                    <div class="comment add-reply ">
                        <ul class="more_reply_box comment_list" id="ul${c._id}">
                            <#list c.refScenicComments as refc>
                                <li>
                                    <a href="#" target="_blank">
                                        <img src="${refc.headUrl}"
                                             width="16" height="16">${refc.username}
                                    </a>
                                    <#if refc.type == 1>
                                    ：${refc.content}
                                    <#else>
                                    回复 ${refc.replyUsername} ：${refc.content}
                                    </#if>
                                    <a class="_j_reply re_reply" data-id="625204" data-uid="63107989"
                                       data-username="${refc.username}" title="添加回复" id="${refc._id}">回复</a>
                                    <br><span class="time">${refc.createTime?string('yyyy-MM-dd HH:mm:ss')}</span>

                                    <div class="add-comment hide reply-form" data-area="${refc._id}" style="display: none;"
                                         data-show="false">
                                        <textarea class="comment_reply " autofocus data-comment_id="${refc._id}"
                                                  data-ScenicId="${refc.scenicId}" style="overflow: hidden; color: rgb(204, 204, 204);"
                                                  placeholder="回复${refc.username}:"></textarea>
                                        <a class="btn btn_submit_reply}" id="reply${refc._id}">回复</a>
                                    </div>
                                </li>
                                <script>
                                    $('#reply${refc._id}').click(function () {
                                        var content = $('textarea[data-comment_id=${refc._id}]').val();
                                        if(!content){
                                            alert("评论不能为空!");
                                            return;
                                        }
                                        $.post('/scenic/refCommentAdd',{scenicId:'${refc.scenicId}',content:content,type:2,'refCommentId':'${c._id}','replyUsername':'${refc.username}'},function (data) {
                                            $('#ul${c._id}').append(data);
                                        })
                                        if(!$('.add-reply').hasClass("comment")){
                                            $('.add-reply').addClass("comment");
                                        }
                                        $('.add-comment').attr('style', 'display: none;')
                                        $('textarea[data-comment_id=${refc._id}]').val('');
                                        flag = false;
                                    })

                                    $('#${refc._id}').click(function () {
                                        if (!flag) {
                                            $('div[data-area=${refc._id}]').attr('style', 'display: block;')
                                            $('textarea[data-comment_id=${refc._id}]').focus()
                                            $('textarea[data-comment_id=${refc._id}]').addClass('focus')
                                            flag = true;
                                        } else if(flag) {
                                            $('.add-comment').attr('style', 'display: none;')
                                            flag = false;
                                        }
                                    })
                                </script>
                            </#list>
                        </ul>
                    </div>
                    <#--</#if>-->

                    <div class="add-comment hide reply-form" data-area="${c._id}" style="display: none;"
                         data-show="false">
                        <textarea class="comment_reply " autofocus data-comment_id="${c._id}"
                                  data-ScenicId="${c.scenicId}"
                                  style="overflow: hidden; color: rgb(204, 204, 204);"
                                  placeholder="发表评论:"></textarea>
                        <a class="btn btn_submit_reply}" id="reply${c._id}">回复</a>
                    </div>

                </li>

                <script>
                    //对点评发表评论
                    $('#reply${c._id}').click(function () {
                        var content = $('textarea[data-comment_id=${c._id}]').val();
                        if(!content){
                            alert("评论不能为空!");
                            return;
                        }
                        $.post('/scenic/refCommentAdd',{scenicId:'${c.scenicId}',content:content,type:1,'refCommentId':'${c._id}','refComment.username':'${c.username}'},function (data) {
                            $('#ul${c._id}').append(data);
                        })
                        if(!$('.add-reply').hasClass("comment")){
                            $('.add-reply').addClass("comment");
                        }
                        $('.add-comment').attr('style', 'display: none;')
                        $('textarea[data-comment_id=${c._id}]').val('');
                        flag = false;
                    })



                    var flag = false;
                    $('#${c._id}').click(function () {
                        if (!flag) {
                            $('div[data-area=${c._id}]').attr('style', 'display: block;')
                            $('textarea[data-comment_id=${c._id}]').focus()
                            $('textarea[data-comment_id=${c._id}]').addClass('focus')
                            flag = true;
                        } else if(flag) {
                            $('.add-comment').attr('style', 'display: none;')
                            flag = false;
                        }
                    })



                    /*$('.comment_reply').blur(function () {
                        $('.reply-form').attr('style', 'display: none;')
                        flag =false;
                    })*/
                </script>
            </#list>
            </ul>
        </div>
    </div>
</#if>
<div style="float: right">
    <div style="float: left;" ><span style="line-height:30px"> 共${page.totalPages!}页 / ${page.totalElements}条&nbsp;&nbsp;&nbsp;</span></div>
    <div id="pagination" class="jq-pagination" style="display: inline;"></div>
</div>
<script>
    //分页
    $("#pagination").jqPaginator({
        totalPages: ${page.totalPages!0},
        visiblePages: 5,
        currentPage: ${page.number+1}||1,
        prev: '<a class="prev" href="javascript:void(0);">上一页<\/a>',
        next: '<a class="next" href="javascript:void(0);">下一页<\/a>',
        page: '<a href="javascript:void(0);">{{page}}<\/a>',
        last: '<a class="last" href="javascript:void(0);" >尾页<\/a>',
        onPageChange: function(page, type) {
            if(type == 'change'){
                $("#currentPage").val(page);
                $("#searchForm").submit();
            }
        }
    })
</script>